//
chrome.extension.sendMessage({type : "getAppSetting"}, init);
//
function init(resp){
    //用于跨域
    var appSetting = resp.data;
    var nodeId = "ex_hidden_app_setting";
    var dataNode = document.getElementById(nodeId);
    if(!dataNode){
        dataNode = document.createElement("input");
        dataNode.id = nodeId;
        dataNode.type = "hidden";
        document.body.appendChild(dataNode);
    }
    dataNode.value = JSON.stringify(appSetting);
    //inject to current domain
    injectJS();
}

function injectJS(){
    var node = document.createElement('script');
    var url = chrome.extension.getURL("contents/override.js?v=2012101702");
    node.setAttribute('type', 'text/javascript');            
    node.setAttribute('src', url);
    document.getElementsByTagName('head')[0].appendChild(node);
}
